package com.xxin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xxin.mapper.RegistryMapper;
import com.xxin.pojo.dto.RegistryDTO;
import com.xxin.pojo.entity.MedicalAdvice;
import com.xxin.pojo.entity.Registry;
import com.xxin.pojo.vo.RegistryVO;
import com.xxin.service.RegistryService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @author 小欣
 * @version 1.0
 * @since 1.8
 */
@Service
public class RegistryServiceImpl implements RegistryService {
	
	
	@Resource
	private RegistryMapper registryMapper;
	
	@Value("${pageHelper.pageSize}")
	private Integer pageSize;
	
	@Override
	public PageInfo<RegistryVO> conditionPageQuery(RegistryDTO registryDTO) {
		PageHelper.startPage(Optional.ofNullable(registryDTO.getPageNum()).orElse(1),pageSize);
		List<RegistryVO> registryVOS = registryMapper.selectByCondition(registryDTO);
		return new PageInfo<>(registryVOS);
	}
	
	@Override
	public void consultationEnd(Long id) {
		registryMapper.updateStatus(id,3);
	}
}
